package com.redxun.core.api.impl;


import com.alibaba.druid.pool.DruidDataSource;
import com.redxun.core.db.datasource.DynamicDataSource;
import com.redxun.core.db.datasource.IDataSourceProxy;
import org.springframework.stereotype.Component;

import javax.sql.DataSource;

/**
 * IDataSourceProxy 接口单体的实现,解决数据源 在单体和分布式中的实现.
 * @author ray
 * @date 2025-03-24
 */
@Component
public class BootDataSourceProxy implements IDataSourceProxy {
    @Override
    public DruidDataSource getDataSource(String alias, DynamicDataSource dynamicDataSource) throws Exception {
        return (DruidDataSource) dynamicDataSource.getDataSource(alias);
    }

    @Override
    public DruidDataSource getRealDataSource(DataSource dataSource) {
        return (DruidDataSource) dataSource;
    }
}
